#include <iostream>
#include <vector>

int Array[] = {3, 5, 1, 8, 4, 7, 6, 9, 0, 2};

void selectSort(int arr[], int arrsize)
{
    int temp = 0;
    for(int i = 0; i < arrsize - 1; i++)
    {
        int minPos = i;
        for(int j = i + 1; j < arrsize; j++)
        {
            if(arr[j] < arr[minPos])
            {
                minPos = j;
            }
        }
        if(minPos != i)
        {
            temp = arr[i];
            arr[i] = arr[minPos];
            arr[minPos] = temp;
        }
    }
}

std::vector<int> VectorArray = {3, 5, 1, 8, 4, 7, 6, 9, 0, 2};

void selectSort(std::vector<int>& arr)
{
    int temp = 0;
    for(int i = 0; i < arr.size() - 1; i++)
    {
        int minPos = i;
        for(int j = i + 1; j < arr.size(); j++)
        {
            if(arr[j] < arr[minPos])
            {
                minPos = j;
            }
        }
        if(minPos != i)
        {
            temp = arr[i];
            arr[i] = arr[minPos];
            arr[minPos] = temp;
        }
    }
}

int main(void)
{
    int size = sizeof(Array) / sizeof(Array[0]);

    std::cout <<"Before Sort:" << std::endl;
    for(int i = 0; i < size; i++)
    {
        std::cout << Array[i] << " ";
    }
    std::cout << std::endl;

    selectSort(Array, size);

    std::cout <<"After Sort:" << std::endl;
    for(int i = 0; i < size; i++)
    {
        std::cout << Array[i] << " ";
    }
    std::cout << std::endl;

    std::cout <<"-------------------------------" << std::endl;
    

    std::cout <<"Before Sort:" << std::endl;
    for(int i = 0; i < VectorArray.size(); i++)
    {
        std::cout << VectorArray[i] << " ";
    }
    std::cout << std::endl;

    selectSort(VectorArray);

    std::cout <<"After Sort:" << std::endl;
    for(int i = 0; i < VectorArray.size(); i++)
    {
        std::cout << VectorArray[i] << " ";
    }
    
    return 0;
}
